package com.mlog.njyjy.ndop.msg.relay.util;

import java.util.Date;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;

public class CustomDateUtil {

	public static Date datetimeParser(String datestr) {
		Date date = datetimeFormatValidator(datestr, null);
		if(date == null)
			date =  datetimeFormatValidator(datestr, "yyyyMMdd HH:mm:ss");
		return date;
	}
	
	public static Date datetimeFormatValidator(String datestr, String format) {
		Date date = null;
		try {
			if (StrUtil.isEmpty(format))
				date = DateUtil.parse(datestr);
			else
				date = DateUtil.parse(datestr, format);
			return date;
		} catch (Exception e) {
			return null;
		}
	}
}
